package com.example.bluetooth;

import android.content.Context;
import android.os.BatteryManager;
 
public class BatteryHelper {
 
    public static int getBatteryLevel(Context context) {
        int batteryLevel = 0;
        BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
        if (batteryManager != null) {
            batteryLevel = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
        }
        return batteryLevel;
    }

}